Previous Book Contents Book Index Next

Inside Macintosh: QuickTime /
Chapter 2 - Movie Toolbox / Movie Toolbox Reference
Data Types


The Time Structure

The Movie Toolbox provides a number of functions that allow you to work with time specifications. These functions are described in "Time Base Functions" beginning on page 2-296. Many of these functions require that you place a time specification in a data structure called a time structure. The time structure allows you to fully describe a time specification. The TimeRecord data type defines the format of a time structure.

struct TimeRecord 
{
   CompTimeValue  value;   /* time value (duration or absolute) */
   TimeScale   scale;      /* units per second */
   TimeBase    base;       /* reference to the time base */
};
typedef struct TimeRecord TimeRecord;
Field Description
value
Contains the time value. The time value defines either a duration or an absolute time by specifying the corresponding number of units of time. For durations, this is the number of time units in the period. For an absolute time, this is the number of time units since the beginning of the time coordinate system. The unit for this value is defined by the scale field.
The time value is expressed as a CompTimeValue data type, which is a 64-bit integer quantity. This 64-bit quantity consists of two 32-bit integers, and it is defined by the Int64 data type, which is described next in this section.
scale
Contains the time scale. This field specifies the number of units of time that pass each second. If you specify a value of 0, the time base uses its natural time scale.
base
Contains a reference to the time base. You obtain a time base by calling the Movie Toolbox's GetMovieTimeBase or NewTimeBase functions (described on page 2-175 and page 2-297, respectively).
If the time structure defines a duration, set this field to nil. Otherwise, this field must refer to a valid time base.
You specify the time value in a time structure in a 64-bit integer value as follows:

typedef Int64 CompTimeValue;
The Movie Toolbox uses this format so that extremely large time values can be represented. The Int64 data type defines the format of these signed 64-bit integers.

struct Int64 
{
   long hi; /* high-order 32 bits-value field in time structure */
   long lo; /* low-order 32 bits-value field in time structure */
};
typedef struct Int64 Int64;
Field Description
hi
Contains the high-order 32 bits of the value. The high-order bit represents the sign of the 64-bit integer.
lo
Contains the low-order 32 bits of the value.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996